<?php

namespace app\traits;

trait DataProcessor
{
    public static function processSwitch(&$data, $fields = [])
    {
        if (!is_array($fields)) {
            $fields = [$fields];
        }

        foreach ($fields as $field) {
            if (!isset($data[$field])) {
                $data[$field] = 0;
            } else {
                $data[$field] = 1;
            }
        }
    }
}